@extends('backstage.layout.master')
@section('title', '版本录入')
@section('style')
    <style>
        .ace-file-input input[type=file]{
            position:static;
        }
        body{
            overflow-x: hidden;
        }
    </style>
@stop
@section('content')
    <div class="breadcrumbs" id="breadcrumbs">
        <script type="text/javascript">
            try {
                ace.settings.check('breadcrumbs', 'fixed')
            } catch (e) {
            }
        </script>
        <ul class="breadcrumb">
            <li>
                <i class="icon-home home-icon"></i>
                <a href="backstage/home">主页</a>
            </li>
            <li class="active">
                <a href="backstage/android/android-version-list">Android版本管理</a>
            </li>
            <li>
                版本录入
            </li>
        </ul><!-- .breadcrumb -->
    </div>
    <div class="page-content">
        <div class="row">
            <div class="col-xs-12">
                <!-- PAGE CONTENT BEGINS -->
                <div class="page-header">
                    <h1>
                        版本录入
                    </h1>
                </div>
                <div class="row">
                    <div class="col-xs-12">
                        <!-- PAGE CONTENT BEGINS -->
                        <form class="form-horizontal" role="form" action="backstage/config/insert-android-version" method="post" enctype="multipart/form-data">
                            <input type="hidden" name="_token" value="<?php echo csrf_token(); ?>">
                            <div class="form-group {{$errors->first('version')!=""?'has-error':''}}">
                                <label class="col-sm-4 control-label no-padding-right" for="version"> 版本名称 </label>
                                <div class="col-sm-4">
                                    <input type="text" name="version_name" id="version_name" class="width-100"
                                    value="{{old('version_name')}}">
                                </div>
                                <div class="col-sm-4">
                                    <div class="help-block col-xs-12 col-sm-reset inline"> {{$errors->first('version_name')}}</div>
                                </div>
                            </div>
                            <div class="space-4"></div>
                            <div class="form-group {{$errors->first('pakage_size')!=""?'has-error':''}}">
                                <label class="col-sm-4 control-label no-padding-right" for="url"> 包大小(23.4M) </label>
                                <div class="col-sm-4">
                                    <input type="text" name="pakage_size" id="pakage_size" class="width-100" value="{{old('pakage_size')}}">
                                </div>
                                <div class="col-sm-4">
                                    <div class="help-block col-xs-12 col-sm-reset inline"> {{$errors->first('pakage_size')}}</div>
                                </div>
                            </div>
                            <div class="space-4"></div>
                            <div class="form-group {{$errors->first('update_describe')!=""?'has-error':''}}">
                                <label class="col-sm-4 control-label no-padding-right" for="update_describe"> 更新描述(回车键换行) </label>
                                <div class="col-sm-4">
                                    <textarea type="text" name="update_describe" id="update_describe" class="width-100" style="min-height:150px">{{old('update_describe')}}</textarea>
                                </div>
                                <div class="col-sm-4">
                                    <div class="help-block col-xs-12 col-sm-reset inline"> {{$errors->first('update_describe')}}</div>
                                </div>
                            </div>
                            <div class="space-4"></div>
                            <div class="form-group {{$errors->first('download_url')!=""?'has-error':''}}">
                                <label class="col-sm-4 control-label no-padding-right" for="download_url"> 下载链接 </label>
                                <div class="col-sm-4">
                                    <textarea type="text" name="download_url" id="download_url" class="width-100">http://</textarea>
                                </div>
                                <div class="col-sm-4">
                                    <div class="help-block col-xs-12 col-sm-reset inline"> {{$errors->first('download_url')}}</div>
                                </div>
                            </div>
                            <div class="space-4"></div>
                            <div class="form-group {{$errors->first('is_must_update')!=""?'has-error':''}}">
                                <label class="col-sm-4 control-label no-padding-right" for="url"> 升级类型 </label>
                                <div class="col-sm-4">
                                    <select id="is_must_update">
                                        <option value="0">可选升级</option>
                                        <option value="1">强制升级</option>
                                    </select>
                                </div>
                                <div class="col-sm-4">
                                    <div class="help-block col-xs-12 col-sm-reset inline"> {{$errors->first('is_must_update')}}</div>
                                </div>
                            </div>
                            <div class="space-4"></div>
                            <div class="form-group {{$errors->first('update_time')!=""?'has-error':''}}">
                                <label class="col-sm-4 control-label no-padding-right" for="url"> 更新时间 </label>
                                <div class="col-sm-4">
                                    <input type="text" name="update_time" id="update_time" class="width-100" value="{{old('update_time')}}">
                                </div>
                                <div class="col-sm-4">
                                    <div class="help-block col-xs-12 col-sm-reset inline"> {{$errors->first('update_time')}}</div>
                                </div>
                            </div>
                            <div class="space-4"></div>
                            <div class="form-group {{$errors->first('version_code')!=""?'has-error':''}}">
                                <label class="col-sm-4 control-label no-padding-right" for="url"> 版本号 </label>
                                <div class="col-sm-4">
                                    <input type="text" name="version_code" id="version_code" class="width-100" value="{{old('version_code')}}">
                                </div>
                                <div class="col-sm-4">
                                    <div class="help-block col-xs-12 col-sm-reset inline"> {{$errors->first('version_code')}}</div>
                                </div>
                            </div>
                            <div class="space-4"></div>
                            <div class="clearfix form-actions">
                                <div class="col-md-offset-5 col-md-9">
                                    <button class="btn btn-info" type="button" onclick="insert()">
                                        <i class="icon-ok bigger-110"></i>
                                        保存
                                    </button>
                                    &nbsp; &nbsp; &nbsp;
                                    <button class="btn" type="reset">
                                        <i class="icon-undo bigger-110"></i>
                                        重置
                                    </button>
                                </div>
                            </div>
                        </form>
                    </div><!-- /.col -->
                </div>
                <!-- PAGE CONTENT ENDS -->
            </div><!-- /.col -->
        </div><!-- /.row -->
    </div><!-- /.page-content -->
@stop
@section('script')
<script>
    function insert(){
        swal('处理中','请稍后','warning');
        var version_name    = $("#version_name").val();
        if(version_name == "" || version_name == undefined){
            swal('请填写版本名称','','success');
            return ;
        }
        var pakage_size     = $("#pakage_size").val();
        if(pakage_size == "" || pakage_size == undefined){
            swal('请填写安装包大小','','success');
            return ;
        }
        var update_describe = $("#update_describe").val();
        if(update_describe == "" || update_describe == undefined){
            swal('请填写更新描述','','success');
            return ;
        }
        var download_url    = $("#download_url").val();
        if(download_url == "" || download_url == undefined){
            swal('请填写下载地址','','success');
            return ;
        }
        var is_must_update  = $("#is_must_update option:selected").val();
        if(is_must_update == "" || is_must_update == undefined){
            swal('请选择升级类型','','success');
            return ;
        }
        var update_time     = $("#update_time").val();
        if(update_time == "" || update_time == undefined){
            swal('请填写更新时间','','success');
            return ;
        }
        var version_code     = $("#version_code").val();
        if(version_code == "" || version_code == undefined){
            swal('请填写版本号','','success');
            return ;
        }

        $.ajax({
            url:"/backstage/config/insert-android-version",
            type:"post",
            data:{"version_name" : version_name,
                  "pakage_size" : pakage_size,
                  "update_describe" : update_describe,
                  "download_url" : download_url,
                  "is_must_update" : is_must_update,
                  "update_time" : update_time,
                  "version_code" : version_code},
            datatype:"json",
            success:function(re){
                if(re.state=="M00000"){
                    swal(re.message,'','success');
                    return;
                }
                swal(re.message,'','warning');
                return;
            },
            error:function(){
                swal('系统繁忙','请稍后重试','warning');
                return;
            }
        });
    }
</script>
@stop
